import { request } from "@/utils/request.js"
import applicationViewMockData from "@/mock/data/application/index.js"


function query(mockDataName) {
    const { integrationData, catalog } = applicationViewMockData;
    const { data: result } = integrationData[catalog.indexOf(mockDataName)];
    return { data: result }
}

/**
 * 基础设施监控告警列表
 * @param {*} options 
 * @returns 
 */
export function getAppListData(options = {}) {
    return request({
        url: `sjzt/sd_monitor/v1/cxlbsj`,
        method: 'get',
        mockFilter: (req, mockDataName = "cxlbsj") => {
            return query(mockDataName)
        },
        params: options
    })

}

/**
 * 云资源使用明细数据
 * @param {*} options 
 * @returns 
 */
export function getYzyListData(options = {}) {
    return request({
        url: `sjzt/yzyqk/yzysymx`,
        method: 'get',
        mockFilter: (req, mockDataName = "yzysymx") => {
            return query(mockDataName)
        },
        params: options
    })

}

/**
 * 云资源开通明细数据
 * @param {*} options 
 * @returns 
 */
export function getsqbListData(options = {}) {
    return request({
        url: `sjzt/szczyzy/sqb`,
        method: 'get',
        mockFilter: (req, mockDataName = "sqb") => {
            return query(mockDataName)
        },
        params: options
    })
}

/**
 * 应用监控_告警详情总览
 * @param {} options 
 * @returns 
 */
export function getAppDetailsData(options = {}) {
    return request({
        url: `sjzt/sd_monitor/v1/yyjk_total`,
        method: 'get',
        mockFilter: (req, mockDataName = "yyjk_total") => {

            return query(mockDataName)
        },
        params: options
    })

}


/**
 * 业务运维Api
 * @param {} options 
 * @returns 
 */
export function getAppBusinessData(options = {}) {
    return request({
        url: `sjzt/sd_monitor/v1/ywyw`,
        method: 'get',
        mockFilter: (req, mockDataName = "ywyw") => {
            return query(mockDataName)
        },
        params: options
    })

}

/**
 * 需求饼图数据
 * @param {} options 
 * @returns 
 */
export function getAppRequirementData(options = {}) {
    return request({
        url: `sjzt/yyjk/xqbt`,
        method: 'get',
        mockFilter: (req, mockDataName = "xqbt") => {
            return query(mockDataName)
        },
        params: options
    })

}

/**
 * 迭代饼图数据
 * @param {} options 
 * @returns 
 */
export function getAppIterationData(options = {}) {
    return request({
        url: `sjzt/yyjk/ddbt`,
        method: 'get',
        mockFilter: (req, mockDataName = "ddbt") => {
            return query(mockDataName)
        },
        params: options
    })

}

/**
 * 缺陷饼图数据
 * @param {} options 
 * @returns 
 */
export function getAppDefectData(options = {}) {
    return request({
        url: `sjzt/yyjk/qxzs`,
        method: 'get',
        mockFilter: (req, mockDataName = "qxzs") => {
            return query(mockDataName)
        },
        params: options
    })

}

/**
 * CPU、内存、储存近30天使用率
 * @param {} options 
 * @returns 
 */
export function getAppUsageRateData(options = {}) {
    return request({
        url: `sjzt/sd_monitor/v1/gcsb`,
        method: 'get',
        mockFilter: (req, mockDataName = "gcsb") => {
            return query(mockDataName)
        },
        params: options
    })

}














